package cn.ronghuanet.basic.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class AjaxResult {
    private Object data;
    private String msg;
    private Boolean success;

    public static AjaxResult success(){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.msg = "操作成功";
        ajaxResult.success = true;
        return ajaxResult;
    }

    public static AjaxResult success(Object obj){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.msg = "操作成功";
        ajaxResult.success = true;
        ajaxResult.data = obj;
        return ajaxResult;
    }
    public static AjaxResult success(Object obj,String msg){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.msg = msg;
        ajaxResult.success = true;
        ajaxResult.data = obj;
        return ajaxResult;
    }

    public static AjaxResult error(){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.msg = "操作失败";
        ajaxResult.success = false;
        return ajaxResult;
    }

    public static AjaxResult error(String msg){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.msg = msg;
        ajaxResult.success = false;
        return ajaxResult;
    }
}
